cmake_minimum_required(VERSION 3.10)
project(loong_third_party VERSION 3.6.0 LANGUAGES C CXX)
option(ARM64 "aarch64" OFF)
if(ARM64)
    set(march aarch64)
else(ARM64)
    set(march x86_64)
endif(ARM64)
set(CMAKE_C_COMPILER ${march}-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${march}-linux-gnu-g++)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_library(ethercat SHARED ethercat/lib/common.c ethercat/lib/domain.c ethercat/lib/master.c ethercat/lib/reg_request.c ethercat/lib/sdo_request.c ethercat/lib/slave_config.c ethercat/lib/soe_request.c ethercat/lib/voe_handler.c)
set_target_properties(ethercat PROPERTIES NO_SONAME ON)
set_target_properties(ethercat PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/ethercat/lib")
target_include_directories(ethercat PUBLIC ${PROJECT_SOURCE_DIR}/ethercat)
add_library(modbus SHARED modbus/src/modbus.c modbus/src/modbus-data.c modbus/src/modbus-ipc.c modbus/src/modbus-rtu.c)
set_target_properties(modbus PROPERTIES NO_SONAME ON)
set_target_properties(modbus PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/modbus/lib")
target_include_directories(modbus PUBLIC ${PROJECT_SOURCE_DIR}/modbus ${PROJECT_SOURCE_DIR}/modbus/include)
add_library(tinyxml2 SHARED tinyxml2/src/tinyxml2.cpp)
set_target_properties(tinyxml2 PROPERTIES NO_SONAME ON)
set_target_properties(tinyxml2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/tinyxml2/lib")
target_include_directories(tinyxml2 PUBLIC ${PROJECT_SOURCE_DIR}/tinyxml2/include)